/*
 * Copyright (c) 2008 Benoit Bouchez, Nicolas Giard
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.noocodecommit.wicket.stuff.jquery.plugin.ui.draggable;

import com.noocodecommit.wicket.stuff.jquery.plugin.JQPluginOptions;

/**
 * JQDraggable Option set
 * 
 * @author Benoit Bouchez
 * 
 */
public class JQDraggableOptions extends JQPluginOptions implements Cloneable
{
	/** x axis value */
	public static final String AXIS_X = "x";
	/** y axis value */
	public static final String AXIS_Y = "y";
	/** Parent containment value */
	public static final String CONTAINMENT_PARENT = "parent";
	/** Document containment value */
	public static final String CONTAINMENT_DOCUMENT = "document";
	/** Original helper value */
	public static final String HELPER_ORIGINAL = "original";
	/** Clone helper value */
	public static final String HELPER_CLONE = "clone";
	/** Inner snap mode value */
	public static final String SNAPMODE_INNER = "inner";
	/** Outer snap mode value */
	public static final String SNAPMODE_OUTER = "outer";

	private String appendTo = "parent";
	private String axis = "";
	private String cancel = "['input', 'textarea', 'button', 'select', 'option']";
	private String containment = "";
	private String cursor = "";
	private String cursorAt;
	private int delay = 0;
	private int distance = 0;
	private String grid = "[1, 1]";
	private String handle = "";
	private String helper = HELPER_ORIGINAL;
	private float opacity = 1f;
	private boolean revert = false;
	private boolean scroll = true;
	private int scrollSensitivity = 20;
	private int scrollSpeed = 20;
	private Object snap = "";
	private String snapMode;
	private int snapTolerance = 1;
	private int zIndex = 0;

	private String startScript = "";
	private String dragScript = "";
	private String stopScript = "";

	/**
	 * Constructor
	 */
	public JQDraggableOptions()
	{
		super();
		this.setDefaultHeader("draggable");
	}

	/**
	 * Gets the appendTo value
	 * 
	 * @return the appendTo value
	 */
	public String getAppendTo()
	{
		return appendTo;
	}

	/**
	 * Sets the appendTo option value
	 * 
	 * @param appendTo
	 *            draggable appendTo
	 */
	public void setAppendTo(String appendTo)
	{
		this.appendTo = appendTo;
		this.options.put("appendTo", "appendTo:'" + appendTo + "'");
	}

	/**
	 * Gets the axis value
	 * 
	 * @return the axis value
	 */
	public String getAxis()
	{
		return axis;
	}

	/**
	 * Sets the axis option value
	 * 
	 * @param axis
	 *            draggable axis
	 */
	public void setAxis(String axis)
	{
		this.axis = axis;
		this.options.put("axis", "axis:'" + axis + "'");
	}

	/**
	 * Gets the cancel value
	 * 
	 * @return the cancel value
	 */
	public String getCancel()
	{
		return cancel;
	}

	/**
	 * Sets the cancel option value
	 * 
	 * @param cancel
	 *            draggable cancel
	 */
	public void setCancel(String cancel)
	{
		this.cancel = cancel;
		this.options.put("cancel", "cancel:" + cancel);
	}

	/**
	 * Gets the containment value
	 * 
	 * @return the containment value
	 */
	public String getContainment()
	{
		return containment;
	}

	/**
	 * Sets the containment option value
	 * 
	 * @param containment
	 *            draggable containment
	 */
	public void setContainment(String containment)
	{
		this.containment = containment;
		this.options.put("containment", "containment:'" + containment + "'");
	}

	/**
	 * Gets the cursor value
	 * 
	 * @return the cursor value
	 */
	public String getCursor()
	{
		return cursor;
	}

	/**
	 * Sets the cursor option value
	 * 
	 * @param cursor
	 *            draggable cursor
	 */
	public void setCursor(String cursor)
	{
		this.cursor = cursor;
		this.options.put("cursor", "cursor:'" + cursor + "'");
	}

	/**
	 * Gets the cursor at value
	 * 
	 * @return the color value
	 */
	public String getCursorAt()
	{
		return cursorAt;
	}

	/**
	 * Sets the cursorAt option value
	 * 
	 * @param cursorAt
	 *            draggable cursorAt
	 */
	public void setCursorAt(String cursorAt)
	{
		this.cursorAt = cursorAt;
		this.options.put("cursorAt", "cursorAt:'" + cursorAt + "'");
	}

	/**
	 * Gets the delay value
	 * 
	 * @return the delay value
	 */
	public int getDelay()
	{
		return delay;
	}

	/**
	 * Sets the delay option value
	 * 
	 * @param delay
	 *            draggable delay
	 */
	public void setDelay(int delay)
	{
		this.delay = delay;
		this.options.put("delay", "delay:" + delay);
	}

	/**
	 * Gets the distance value
	 * 
	 * @return the distance value
	 */
	public int getDistance()
	{
		return distance;
	}

	/**
	 * Sets the distance option value
	 * 
	 * @param distance
	 *            draggable distance
	 */
	public void setDistance(int distance)
	{
		this.distance = distance;
		this.options.put("distance", "distance:" + distance);
	}

	/**
	 * Gets the grid value
	 * 
	 * @return the grid value
	 */
	public String getGrid()
	{
		return grid;
	}

	/**
	 * Sets the grid option value
	 * 
	 * @param grid
	 *            draggable grid
	 */
	public void setGrid(String grid)
	{
		this.grid = grid;
		this.options.put("grid", "grid:" + grid);
	}

	/**
	 * Gets the handle value
	 * 
	 * @return the handle value
	 */
	public String getHandle()
	{
		return handle;
	}

	/**
	 * Sets the handle option value
	 * 
	 * @param handle
	 *            draggable handle
	 */
	public void setHandle(String handle)
	{
		this.handle = handle;
		this.options.put("handle", "handle:'" + handle + "'");
	}

	/**
	 * Gets the helper value
	 * 
	 * @return the helper value
	 */
	public String getHelper()
	{
		return helper;
	}

	/**
	 * Sets the helper option value
	 * 
	 * @param helper
	 *            draggable helper
	 */
	public void setHelper(String helper)
	{
		this.helper = helper;
		this.options.put("helper", "helper:'" + helper + "'");
	}

	/**
	 * Gets the opacity value
	 * 
	 * @return the opacity value
	 */
	public float getOpacity()
	{
		return opacity;
	}

	/**
	 * Sets the opacity option value
	 * 
	 * @param opacity
	 *            draggable opacity
	 */
	public void setOpacity(float opacity)
	{
		this.opacity = opacity;
		this.options.put("opacity", "opacity:" + opacity);
	}

	/**
	 * Gets the revert value
	 * 
	 * @return the revert value
	 */
	public boolean isRevert()
	{
		return revert;
	}

	/**
	 * Sets the revert option value
	 * 
	 * @param revert
	 *            draggable revert
	 */
	public void setRevert(boolean revert)
	{
		this.revert = revert;
		this.options.put("revert", "revert:" + revert);
	}

	/**
	 * Gets the scroll value
	 * 
	 * @return the scroll value
	 */
	public boolean isScroll()
	{
		return scroll;
	}

	/**
	 * Sets the scroll option value
	 * 
	 * @param scroll
	 *            draggable scroll
	 */
	public void setScroll(boolean scroll)
	{
		this.scroll = scroll;
		this.options.put("scroll", "scroll:" + scroll);
	}

	/**
	 * Gets the scroll sensitivity value
	 * 
	 * @return the scroll sensitivity value
	 */
	public int getScrollSensitivity()
	{
		return scrollSensitivity;
	}

	/**
	 * Sets the scroll sensitivity option value
	 * 
	 * @param scrollSensitivity
	 *            draggable scroll sensitivity
	 */
	public void setScrollSensitivity(int scrollSensitivity)
	{
		this.scrollSensitivity = scrollSensitivity;
		this.options.put("scrollSensitivity", "scrollSensitivity:" + scrollSensitivity);
	}

	/**
	 * Gets the scroll speed value
	 * 
	 * @return the scroll speed value
	 */
	public int getScrollSpeed()
	{
		return scrollSpeed;
	}

	/**
	 * Sets the scroll speed option value
	 * 
	 * @param scrollSpeed
	 *            draggable scroll speed
	 */
	public void setScrollSpeed(int scrollSpeed)
	{
		this.scrollSpeed = scrollSpeed;
		this.options.put("scrollSpeed", "scrollSpeed:" + scrollSpeed);
	}

	/**
	 * Gets the snap value
	 * 
	 * @return the snap value
	 */
	public Object getSnap()
	{
		return snap;
	}

	/**
	 * Sets the snap option value
	 * 
	 * @param snap
	 *            draggable snap
	 */
	public void setSnap(boolean snap)
	{
		this.snap = snap;
		this.options.put("snap", "snap:" + snap);
	}

	/**
	 * Sets the snap option value
	 * 
	 * @param snap
	 *            draggable snap
	 */
	public void setSnap(String snap)
	{
		this.snap = snap;
		this.options.put("snap", "snap:'" + snap + "'");
	}

	/**
	 * Gets the snap mode value
	 * 
	 * @return the snap mode value
	 */
	public String getSnapMode()
	{
		return snapMode;
	}

	/**
	 * Sets the snapMode option value
	 * 
	 * @param snapMode
	 *            draggable snap mode
	 */
	public void setSnapMode(String snapMode)
	{
		this.snapMode = snapMode;
		this.options.put("snapMode", "snapMode:'" + snapMode + "'");
	}

	/**
	 * Gets the snap tolerance value
	 * 
	 * @return the snap tolerance value
	 */
	public int getSnapTolerance()
	{
		return snapTolerance;
	}

	/**
	 * Sets the snapTolerance option value
	 * 
	 * @param snapTolerance
	 *            draggable snapTolerance
	 */
	public void setSnapTolerance(int snapTolerance)
	{
		this.snapTolerance = snapTolerance;
		this.options.put("snapTolerance", "snapTolerance:" + snapTolerance);
	}

	/**
	 * Gets the z-index value
	 * 
	 * @return the z-index value
	 */
	public int getZIndex()
	{
		return zIndex;
	}

	/**
	 * Sets the zIndex option value
	 * 
	 * @param index
	 *            draggable zIndex
	 */
	public void setZIndex(int index)
	{
		zIndex = index;
		this.options.put("index", "zIndex:" + index);
	}

	/**
	 * Gets the start script value
	 * 
	 * @return the start script value
	 */
	public String getStartScript()
	{
		return startScript;
	}

	/**
	 * Sets the start function
	 * 
	 * @param startScript
	 *            draggable start function
	 */
	public void setStartScript(String startScript)
	{
		this.startScript = startScript;
		this.options.put("start", "start:function(e, ui){" + startScript + "}");
	}

	/**
	 * Gets the drag script value
	 * 
	 * @return the drag script value
	 */
	public String getDragScript()
	{
		return dragScript;
	}

	/**
	 * Sets the drag function
	 * 
	 * @param dragScript
	 *            draggable drag function
	 */
	public void setDragScript(String dragScript)
	{
		this.dragScript = dragScript;
		this.options.put("drag", "drag:function(e, ui){" + dragScript + "}");
	}

	/**
	 * Gets the stop script value
	 * 
	 * @return the stop script value
	 */
	public String getStopScript()
	{
		return stopScript;
	}

	/**
	 * Sets the stop function
	 * 
	 * @param stopScript
	 *            draggable stop function
	 */
	public void setStopScript(String stopScript)
	{
		this.stopScript = stopScript;
		this.options.put("stop", "stop:function(e, ui){" + stopScript + "}");
	}

	@Override
	protected Object clone() throws CloneNotSupportedException
	{
		JQDraggableOptions clone = (JQDraggableOptions) super.clone();
		return clone;
	}
}
